package com.jrx.anytxn.reporting.job.xib.step;

import com.jrx.anytxn.reporting.entity.AmlIATrading;
import com.jrx.anytxn.reporting.job.xib.bean.AmlIATradingBean;
import com.jrx.anytxn.reporting.mapper.base.AmlIATradingMapper;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.batch.item.ItemWriter;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TradingPaymentWriter implements ItemWriter<AmlIATradingBean> {

    @Resource
    private AmlIATradingMapper amlIATradingMapper;


    @Override
    public void write(List<? extends AmlIATradingBean> items) throws Exception {
        if(CollectionUtils.isNotEmpty(items)){
            for(AmlIATradingBean bean : items){
                List<AmlIATrading> amlIATradings = bean.getAmlIATradingList();
                if(CollectionUtils.isNotEmpty(amlIATradings)){
                    for(AmlIATrading amlIATrading : amlIATradings){
                        amlIATradingMapper.insertSelective(amlIATrading);
                    }
                }
            }
        }
    }
}
